<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style type="text/css">
    * {
      padding: 0;
      margin: 0;
    }

    li {
      list-style: none;
    }

    body {
      background: #f6f9fc;
      font-family: arial;
    }

    .calendar {
      width: 210px;
      margin: 0 auto;
      padding: 10px 10px 20px 20px;
      background: #eae9e9;
    }

    .calendar ul {
      width: 210px;
      overflow: hidden;
      padding-bottom: 10px;
    }

    .calendar li {
      float: left;
      width: 58px;
      height: 54px;
      margin: 10px 10px 0 0;
      border: 1px solid #fff;
      background: #424242;
      color: #fff;
      text-align: center;
      cursor: pointer;
    }

    .calendar li h2 {
      font-size: 20px;
      padding-top: 5px;
    }

    .calendar li p {
      font-size: 14px;
    }

    .calendar .active {
      border: 1px solid #424242;
      background: #fff;
      color: #e84a7e;
    }

    .calendar .active p {
      font-weight: bold;
    }

    .calendar .text {
      width: 178px;
      padding: 0 10px 10px;
      border: 1px solid #fff;
      padding-top: 10px;
      background: #f1f1f1;
      color: #555;
    }

    .calendar .text h2 {
      font-size: 14px;
      margin-bottom: 10px;
    }

    .calendar .text p {
      font-size: 12px;
      line-height: 18px;
    }
  </style>
</head>

<body>
  <div id="tab" class="calendar">
    <ul id="ul">
      <li class="active">
        <h2>1</h2>
        <p>JAN</p>
      </li>
      <li>
        <h2>2</h2>
        <p>FER</p>
      </li>
      <li>
        <h2>3</h2>
        <p>MAR</p>
      </li>
      <li>
        <h2>4</h2>
        <p>APR</p>
      </li>
      <li>
        <h2>5</h2>
        <p>MAY</p>
      </li>
      <li>
        <h2>6</h2>
        <p>JUN</p>
      </li>
      <li>
        <h2>7</h2>
        <p>JUL</p>
      </li>
      <li>
        <h2>8</h2>
        <p>AUG</p>
      </li>
      <li>
        <h2>9</h2>
        <p>SEP</p>
      </li>
      <li>
        <h2>10</h2>
        <p>OCT</p>
      </li>
      <li>
        <h2>11</h2>
        <p>NOV</p>
      </li>
      <li>
        <h2>12</h2>
        <p>DEC</p>
      </li>
    </ul>

    <div class="text" id="txt">
      <h2>1月活动</h2>
      <p>快过年了，大家可以商量着去哪玩吧～</p>
    </div>

  </div>
  <script>
    let tab = document.querySelector("#tab");
    let lis = tab.querySelectorAll("ul li")
    let txt_month = document.querySelector(".text h2"); //对应的h2标题，月份
    let txt_show = document.querySelector(".text p"); //对应的p，展示的内容

    lis.forEach((v, i) => {

      lis[i].onclick = function () {
        let that = this; //把当前点击对象的this存起来

        //这个排他思想
        lis.forEach((v, i) => {
          lis[i].className = ""
          txt_month.innerHTML = ""
        })
        //1:给点击的对象，单独添加类名
        that.className = "active"

        //2：下面月份的修改内容
        txt_month.innerHTML = `${i+1}月活动`

        //3：下面的展示修改内容
        switch (i) {
          case 0:
            txt_show.innerHTML = "快过年了，大家可以商量着去哪玩吧～";
            break;
          case 1:
            txt_show.innerHTML = "2月的微风轻拂啊";
            break;
          case 2:
            txt_show.innerHTML = "3月的你，逝水流年";
            break;
          case 3:
            txt_show.innerHTML = "四月的你，樱花灿烂，笑容满面";
            break;
          case 4:
            txt_show.innerHTML = "五月的你，到处繁花似锦";
            break;
          case 5:
            txt_show.innerHTML = "六月的你，小荷才露尖尖角";
            break;
          case 6:
            txt_show.innerHTML = "七月的你，夜空萤火虫闪烁";
            break;
          case 7:
            txt_show.innerHTML = "八月的你，桂花飘香，江河水涨";
            break;
          case 8:
            txt_show.innerHTML = "九月的你，香山红似火";
            break;
          case 9:
            txt_show.innerHTML = "十月的你，瓜果飘香";
            break;
          case 10:
            txt_show.innerHTML = "十一月的你，微风起，秋叶落";
            break;
          case 11:
            txt_show.innerHTML = "十二月的你，银装素裹";
            break;
          default:
            txt_show.innerHTML = "额，你来搞事情的吧？";
        }

      }

    })
  </script>
</body>

</html>